< previous page page_462 next page >

Page 462
e10a6a0a59f035e870d90cca05b85fce.gif
    Next i
    AddPoint = i

    ' If so, we're done.
    If i <= NumPoints Then Exit Function

    ' Otherwise create the new point.
    NumPoints = NumPoints + 1
    ReDim Preserve Points(1 To NumPoints)
    Points(i).coord(1) = x
    Points(i).coord(2) = y
    Points(i).coord(3) = z
    Points(i).coord(4) = 1#
End Function
The AddSegment routine adds one or more segments to a Polyline3d object. This routine uses the ParamArray keyword to take a variable number of point coordinates as parameters. AddSegment creates new segments in the object to connect each point to the one after it in the parameter list.
e10a6a0a59f035e870d90cca05b85fce.gif
' Add one or more line segments to the polyline.
Public Sub AddSegment(ParamArray coord() As Variant)
Dim num_segs As Integer
Dim i As Integer
Dim last As Integer
Dim pt As Integer

    num_segs = (UBound(coord) + 1) \ 3 - 1
    ReDim Preserve Segs(1 To NumSegs + num_segs)

    last = AddPoint((coord(0)), (coord(1)), (coord(2)))
    pt = 0
    For i = 1 To num_segs
        Segs(NumSegs + i).pt1 = last
        pt = pt + 3
        last = AddPoint((coord(pt)), _
             (coord(pt + 1)), (coord(pt + 2)))
        Segs(NumSegs + i).pt2 = last
    Next i

    NumSegs = NumSegs + num_segs 
End Sub
The Polyline3d class also includes subroutine Transform, which applies a distorting transformation to the points that make up the object. This routine takes as a parameter an object representing a distorting transformation, and that has a transform subroutine. The Polyline3d object invokes that object's Transform routine for each of the points that make up the object.
e10a6a0a59f035e870d90cca05b85fce.gif
' Apply a nonlinear transformation.
Public Sub Transform(ByVal T As Object)

 
< previous page page_462 next page >